package tcu.se.testing.junit5;

public class Reversion {
    String reverse (String s){
        if(s == null || s.isEmpty()){
            throw new IllegalArgumentException("不能为空");
        }
        if(!s.matches("[0-9|a-z|A-Z]+")){
            throw new IllegalArgumentException("必须为数字或字母");
        }

        int length = s.length();
        if(length == 1){
            return s;
        }
        String lastChar = s.substring(length -1);
        return lastChar + reverse(s.substring(0,length-1));

    }
}